/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @Title: DataMaskingResponseBody
 * @Package com.rx.core.interceptor
 * @Description: 脱敏拦截
 * @author: 陈锦韬
 * @date: 2020\8\16 0016
 * @version V1.0
 * @Copyright: 2020 陈锦韬  All rights reserved.
 */
package com.rx.core.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;

/**
 * @author: Administrator
 * @Description: 脱敏拦截
 * @date: 2020\8\16 0016
 */
@Slf4j
@ControllerAdvice
public class DataMaskingResponseBody implements ResponseBodyAdvice {

    @Override
    public Object beforeBodyWrite(Object o,
                                  MethodParameter methodParameter,
                                  MediaType mediaType,
                                  Class aClass,
                                  ServerHttpRequest serverHttpRequest,
                                  ServerHttpResponse serverHttpResponse) {

        log.info("DataMaskingResponseBody==>beforeBodyWrite:" + o.toString() + ","
                + methodParameter);
        return o;
    }


    @Override
    public boolean supports(MethodParameter methodParameter, Class aClass) {
        return true;
    }
}
